package com.it.palindromicnumber;

import java.util.Scanner;

public class PalindromicNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数，判断是否为回文数");
        int x = sc.nextInt();
        PalindromicNumber pn = new PalindromicNumber();
        if (pn.isPalindrome(x)) {
            System.out.println(x + " 是回文数");
        } else {
            System.out.println(x + " 不是回文数");
        }

    }
    public boolean isPalindrome(int x) {
        if(x < 0)
            return false;
        int cur = 0;
        int num = x;
        while(num != 0) {
            cur = cur * 10 + num % 10;
            num /= 10;
        }
        return cur == x;
    }
}
